package com.ruoyi.web.controller.vidiomonitor;
/**
 * ClassName: ResourceInfoController <br/>
 * Description: <br/>
 * date: 2020/12/31 14:08<br/>
 *
 * @author Hesion<br />
 * @version
 * @since JDK 1.8
 */

import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.hikvisionutils.HikVisionUtils;
import com.ruoyi.common.utils.hikvisionutils.model.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @program: ruoyi
 * @description: 资源信息接口
 * @author: hesion
 * @create: 2020-12-31 14:08
 **/
@Api("资源信息相关接口。")
@RestController
@RequestMapping("/videoapi/resource")
public class ResourceInfoController {


    /**
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @Author hst
     * @Description //TODO 根据条件查询目录下有权限的资源列表。
     * @Date 14:31 2020/12/31
     * @Param [resourcesByParams]
     **/
    @ApiOperation("查询资源列表v2")
    @ApiImplicitParam(name = "resourcesByParams", value = "请求的参数对象", dataType = "NodesByParams")
    @RequestMapping(value = "/resourcesByParams", method = RequestMethod.POST)
    public AjaxResult getSubResourcesByParams(@RequestBody ResourcesByParams resourcesByParams) {
        String body = HikVisionUtils.getSubResourcesByParams(resourcesByParams).getBody();
        HIKResponseResult hikResponseResult = JSONObject.parseObject(body, HIKResponseResult.class);
        return AjaxResult.success(hikResponseResult.getData());
    }


    /**
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @Author hst
     * @Description //TODO  根据区域编码、资源类型、资源操作权限码分页获取当前区域下（不包含子区域）有权限的资源列表，主要用于逐层获取区域下的资源信息。
     * @Date 14:31 2020/12/31
     * @Param [resourcesByParams]
     **/
    @ApiOperation("根据区域获取下级资源列表v2")
    @ApiImplicitParam(name = "subResourceByRegion", value = "请求的参数对象", dataType = "SubResourceByRegion")
    @RequestMapping(value = "/subResources", method = RequestMethod.POST)
    public AjaxResult getSubResourcesByRegion(@RequestBody SubResourceByRegion subResourceByRegion) {
        String body = HikVisionUtils.getSubResourcesByRegion(subResourceByRegion).getBody();
        HIKResponseResult hikResponseResult = JSONObject.parseObject(body, HIKResponseResult.class);
        return AjaxResult.success(hikResponseResult.getData());
    }

    @ApiOperation("获取资源列表v2")
    @ApiImplicitParam(name = "resourceParams", value = "请求的参数对象", dataType = "ResourceParams")
    @RequestMapping(value = "/resources", method = RequestMethod.POST)
    public AjaxResult getResources(@RequestBody ResourceParams resourceParams) {
        String body = HikVisionUtils.getResources(resourceParams).getBody();
        HIKResponseResult hikResponseResult = JSONObject.parseObject(body, HIKResponseResult.class);
        return AjaxResult.success(hikResponseResult.getData());
    }
    /**
     * @return com.ruoyi.common.core.domain.AjaxResult
     * @Author hst
     * @Description //TODO 根据资源类型、资源编号查询单个资源详细信息，主要用于单个资源信息的展示。
     * @Date 14:58 2020/12/31
     * @Param [resourceParams]
     **/
    @ApiOperation("获取单个资源信息")
    @ApiImplicitParam(name = "singleRourceParams", value = "请求的参数对象", dataType = "SingleRourceParams")
    @RequestMapping(value = "/singleResources", method = RequestMethod.POST)
    public AjaxResult getSingleRource(@RequestBody SingleRourceParams singleRourceParams) {
        String body = HikVisionUtils.getSingleResources(singleRourceParams).getBody();
        HIKResponseResult hikResponseResult = JSONObject.parseObject(body, HIKResponseResult.class);
        return AjaxResult.success(hikResponseResult.getData());
    }



}
